
const mysql = require('mysql2');


let pool;
async function init() {
  // create the connection
  pool = await mysql.createPool({ host: '43.154.190.123', user: 'epaper', password: 'epaper', database: 'epaper' });
  // console.log(pool);
}
init()

async function db(ctx, next) {
  // console.log(pool);
  const promisePool = pool.promise();
  ctx.promisePool = promisePool
  next();
}

module.exports = db